import plugin from "../../lib/plugins/plugin.js";
import { segment } from 'oicq';
import fetch from "node-fetch";

export class xh extends plugin {
  constructor() {
    super({
      name: "可爱",
      dsc: "简单开发示例",
      event: "message",
      priority: 5000,
      rule: [
        {
          reg: "^#*(三次元可爱)$",
          fnc: "scy",
        },
        {
          reg: "^#*(二次元可爱)$",
          fnc: "ecy",
        },
      ],
    });
  }
  
  async scy(e) {
    logger.info('[用户命令]', e.msg)
    
    let url = `https://api.ilolicon.com/sese`;
    
    let response = await fetch(url);
    
    let res = await response.text();

    let msg = [
	    segment.image(url)
    ];

    await this.reply(msg)
  
  }
  async ecy(e) {
    logger.info('[用户命令]', e.msg)
    
    let url = `https://api.ilolicon.com/sese-2`;
    
    let response = await fetch(url);
    
    let res = await response.text();

    let msg = [
	    segment.image(url)
    ];

    await this.reply(msg)
  
  }
}